﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// Simple Service Administration Tool for WinNT based systems.
// Copyright © 2010 - Silvan Gehrig
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
// 
// Author:
//  Silvan Gehrig
//
// ---------------------------------------------------------------------
#endregion

#region Usings

using SSATool.BL.DM;
using SSATool.Common.Util;

#endregion

namespace SSATool.UI.ViewModel
{
    /// <summary>
    /// Represents the UI data container.
    /// </summary>
    public class DataContext
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        private readonly DomainContext _domainContext;
        private DataConnection _dataConnection;
        private DataServiceCollection _dataServices;

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the underlying data connection instance.
        /// </summary>
        public DataConnection Connection
        {
            get
            {
                if (_dataConnection == null)
                    _dataConnection = new DataConnection(_domainContext.Connection);
                return _dataConnection;
            }
        }

        /// <summary>
        /// Gets a list of windows services.
        /// </summary>
        public DataServiceCollection Services
        {
            get
            {
                if (_dataServices == null)
                    _dataServices = new DataServiceCollection(_domainContext.Services);
                return _dataServices;
            }
        }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="DataContext"/> class.
        /// </summary>
        public DataContext(DomainContext domainContext)
        {
            PreCondition.AssertNotNull(domainContext, "domainContext");

            _domainContext = domainContext;
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}
